﻿<UserControl x:Class="Collab.Modules.ContactBrowser.View.SearchContactView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:vm="clr-namespace:Collab.Modules.ContactBrowser.ViewModel"
         xmlns:view="clr-namespace:Collab.Modules.ContactBrowser.View"
         mc:Ignorable="d" 
         d:DesignHeight="197" d:DesignWidth="299">
    <UserControl.Resources>

        <ContextMenu x:Key="ListBoxItemContextMenu">
            <MenuItem x:Name="AddToContacts" Header="Add To Contacts" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
                                    AncestorType=ListBox}, Path=DataContext.AddContactCommand}" />
            <MenuItem x:Name="InviteToGroup" Header="Invite To Group" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
                                    AncestorType=ListBox}, Path=DataContext.InviteToGroupCommand}" />
        </ContextMenu>

        <Style TargetType="{x:Type ListBoxItem}" x:Key="ContactListBoxItem">
            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" 
                    Color="AliceBlue"/>
                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" 
                    Color="Transparent"/>
            </Style.Resources>
            <Setter Property="ContextMenu" Value="{StaticResource ListBoxItemContextMenu}" />
        </Style>

        <DataTemplate x:Key="ContactListTemplate">
            <Border>
                <StackPanel Orientation="Horizontal">
                    <TextBlock x:Name="ContactName" Text="{Binding Path=UserName}" />
                </StackPanel>
            </Border>
        </DataTemplate>

    </UserControl.Resources>

    <StackPanel>

        <Grid Margin="0,10">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="6" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <TextBox Grid.Row="0" Grid.Column="0" x:Name="SearchTextBox" IsReadOnly="False" />
            <Button Grid.Row="0" Grid.Column="2" x:Name="SearchButton" Content="Search" Command="{Binding SearchUsersCommand}" 
                CommandParameter="{Binding ElementName=SearchTextBox, Path=Text}" Padding="10,0"></Button>

        </Grid>

        <ListBox x:Name="UsersFromSearch" Height="300" ItemsSource="{Binding Path=Users}" ItemTemplate="{StaticResource ContactListTemplate}"
                 ItemContainerStyle="{StaticResource ContactListBoxItem}" SelectedItem="{Binding Path=SelectedUser}" >
        
        </ListBox>
    </StackPanel>
</UserControl>
